package com.netease.xone.activity;

import Utils.StackTraceUtil;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import com.netease.log.NTLog;
import com.netease.pkgRelated.XoneConsts;
import com.netease.xone.R;
import com.netease.xone.fragment.FragmentTipBase;
import com.netease.xone.fragment.FragmentTipSubject;
import com.netease.xone.fragment.FragmentTipTopic;
import com.netease.xone.fragment.FragmentTipUserOrSource;
import com.netease.xone.itemview.ItemViewTipBase;


public class ActivityDiscussTip extends ActivityX1Base {

    private static final String TAG = ActivityDiscussTip.class.getSimpleName();
    private FragmentTipBase mFragment = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        NTLog.d(TAG, StackTraceUtil.getMethodName()
                + " savedInstanceState=" + (null == savedInstanceState ? "null" : savedInstanceState.toString()));
        super.onCreate(savedInstanceState);
        
        FrameLayout linear = new FrameLayout(this);
        linear.setId(R.id.activity_discuss_tip_container_id);
        setContentView(linear);
        
        int type = getIntent().getIntExtra(XoneConsts.EXTRA_OPERATE, ItemViewTipBase.TYPE_USER);
        if (null != findViewById(R.id.activity_discuss_tip_container_id) && savedInstanceState == null) {
            if (null == savedInstanceState) {
                FragmentManager fm = getSupportFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                switch (type) {
                    case ItemViewTipBase.TYPE_USER:
                        mFragment = FragmentTipUserOrSource.newInstance(null);
                        break;
                    case ItemViewTipBase.TYPE_SUBJECT:
                        mFragment = FragmentTipSubject.newInstance(null);
                        break;
                    case ItemViewTipBase.TYPE_TOPIC:
                        mFragment = FragmentTipTopic.newInstance(null);
                        break;
                }
                ft.replace(R.id.activity_discuss_tip_container_id, mFragment, TAG);
                ft.commit();
            }
        }
    }
    
    @Override
    protected void onDestroy() {
        NTLog.d(TAG, StackTraceUtil.getMethodName());
        super.onDestroy();
        mFragment = null;
    }

}
